package com.qf.aop;

import org.aopalliance.intercept.MethodInterceptor;
import org.aopalliance.intercept.MethodInvocation;


/**
 * @author YDW
 * projectName:project2202_3
 * time:2022/5/5 19:49
 * description:
 */
public class MyAroundAdvice implements MethodInterceptor {

    @Override
    public Object invoke(MethodInvocation methodInvocation) throws Throwable {
        Object result = null;

        try {
            System.out.println("前置增强");
            //调用原始（真实）方法执行
            result = methodInvocation.proceed();
            System.out.println("后置增强");
        } catch (Throwable e) {
            e.printStackTrace();
            System.out.println("异常增强");
        } finally {
            System.out.println("最终增强");
        }


        return result;
    }
}
